home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-02-17 | 2.5 KB | 110 lines | [TEXT/ROSA] |
- ;;;;
- ;;;; PowerLisp graphics routines
- ;;;; Copyright (c) 1994 Roger Corman
- ;;;;
-
- (defpackage graphics
- (:use :common-lisp)
- (:export
- open-canvas
- use-canvas
- moveto
- lineto
- setcolor
- pensize
- fillrect
- fillpoly
- clear-canvas))
-
- (in-package :graphics)
- (provide :graphics)
-
- (defvar *current-canvas* nil)
- (defvar *current-point* nil)
- (defvar *current-color* nil)
-
- (defun open-canvas (canvas-name)
- "Usage: (open-canvas canvas-name)
- Creates a canvas with the requested name."
- (%new-canvas canvas-name)
- (setq *current-point* nil)
- (setq *current-canvas* canvas-name))
-
- (defun use-canvas (canvas-name)
- "Usage: (use-canvas canvas-name)
- Makes the requested canvas the current canvas."
- (setq *current-point* nil)
- (setq *current-canvas* canvas-name))
-
- (defun moveto (x y)
- "Usage: (moveto x y)
- x and y should be integers and are relative to the upper left
- corner of the canvas."
- (setq *current-point* (cons x y)))
-
- (defun lineto (x y)
- "Usage: (lineto x y)
- x and y should be integers and are relative to the upper left
- corner of the canvas."
- (unless *current-point*
- (error "No current point"))
- (%line *current-canvas*
- (car *current-point*)
- (cdr *current-point*)
- x y)
- (setq *current-point* (cons x y)))
-
- (defun setcolor (r g b)
- "Usage: (setcolor red green blue)
- Sets the current canvas color to the requested RGB color.
- Red, green and blue should be between 0.0 and 1.0"
- (let ((red (truncate (* r 65535)))
- (green (truncate (* g 65535)))
- (blue (truncate (* b 65535))))
- (%rgbforecolor *current-canvas* red green blue)
- (setq *current-color* (list red green blue))))
-
- (defun pensize (size)
- "Usage: (pensize size)
- The current canvas pen size is set to the requested dimension.
- size should be an integer."
- (%pensize *current-canvas* size size))
-
- (defun fillrect (x1 y1 x2 y2)
- "Usage: (fillrect x1 y1 x2 y2)
- A filled rectangle as drawn on the current canvas, using
- the current color."
- (%fill-polygon *current-canvas*
- `((,x1 . ,y1) (,x2 . ,y1) (,x2 . ,y2) (,x1 . ,y2))))
-
- (defun fillpoly (&rest points)
- "Usage: (fillpoly points)
- A filled polygon as drawn on the current canvas, using
- the current color.
- The points list is a list of cons pairs where each cons contains
- two integers (x and y)."
- (%fill-polygon *current-canvas* points))
-
- (defun clear-canvas ()
- "Usage: (clear-canvas)
- The current canvas is erased."
- (%erase-canvas *current-canvas*))
-
- ;;;; Import all these symbols into Common Lisp package
- (in-package :common-lisp)
-
- (use-package :graphics)
-
-
-
-
-
-
-
-
-
-
-
-
-
-